﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ClassLibrary.Data;
using System.Data;
using ClassLibrary.Entity;

namespace ClassLibrary.DAO
{
   public class TblPartUsedDAO
    {
         private DBService _db = null;
         public TblPartUsedDAO(string ConnectionString)
        {
            _db = new DBService(ConnectionString);
        }
         public DataTable InsUpPartUsed(TblPartUsed partUsed, int mode)
         {
             DataTable flag = null;
             try
             {
                 flag = _db.ExeSP_DataTable("sp_PartUsed_InsUp",
                      new string[] { "@PartID", "@JobID", "@ProductID","@PhoneBrand", "@Model", "@PartDescription", "@Quantity", "@Date", "@Mode"},
                      new object[] { partUsed.ID, partUsed.JobID, partUsed.ProductID , partUsed.PhoneBrand, partUsed.PhoneModel,
                          partUsed.PartDescription, partUsed.Quantity, partUsed.DateEntered, mode}, CommandType.StoredProcedure);
             }
             catch (Exception ex)
             {
                 throw ex;
             }
             return flag;
         }

         public DataTable GetPartUsed(int JobID)
         {
             DataTable dt = null;
             try
             {
                 dt = _db.ExeSP_DataTable("sp_GetPartUsed",
                     new string[] { "@ID"},
                     new object[] { JobID }, CommandType.StoredProcedure);
             }
             catch (Exception ex)
             {
                 throw ex;
             }
             return dt;
         }
    }
}
